package com.warmheart.core.rs.builder;

import com.warmheart.core.cors.builder.CoRsBuilder;
import com.warmheart.core.rs.enums.SmTypeEnum;

/**
 * 
 * @ClassName: RsBuilder
 * @Description: 自定义返回值核心接口
 * @author ZhangJianyang
 * @date 2025-06-16 09:37:02
 *
 * @param <T>
 */
public interface RsBuilder<T extends CoRsBuilder<?, ?>> {

    /**
     * 
     * @Title: core
     * @Description: 核心对象
     * @author ZhangJianyang
     * @return
     */
    public T core();

    /**
     * 
     * @Title: clear
     * @Description: 清理对象响应设置
     * @author ZhangJianyang
     * @return
     */
    default T clear() {
        this.core().getDistinctModel().setDistinctFlag(true);
        this.core().getDistinctModel().setSmType(SmTypeEnum.MULTIPLE.getValue());
        this.core().getSelectedModelList().clear();
        return this.core();
    }

    /**
     * 
     * @Title: singleWarpper
     * @Description: 单字段包装
     * @author ZhangJianyang
     * @return
     */
    default void singleWarpper(Boolean... distinctFlags) {
        RsWarpper.custom(this.core()).singleWarpper(distinctFlags);
    }

    /**
     * 
     * @Title: multipleWarpper
     * @Description: 多字段包装
     * @author ZhangJianyang
     * @return
     */
    default void multipleWarpper(Boolean... distinctFlags) {
        RsWarpper.custom(this.core()).multipleWarpper(distinctFlags);
    }

    /**
     * 
     * @Title: groupByCnt
     * @Description: 指定字段分组查询数量
     * @author ZhangJianyang
     * @param distinctFlags
     */
    default void groupByCnt(Boolean... distinctFlags) {
        RsWarpper.custom(this.core()).groupByCnt(distinctFlags);
    }

    /**
     * 
     * @Title: keyValue
     * @Description: 查询KEY以及VALUE映射列表
     * @author ZhangJianyang
     * @param distinctFlags
     */
    default void keyValue(Boolean... distinctFlags) {
        RsWarpper.custom(this.core()).keyValue(distinctFlags);
    }

    /**
     * 
     * @Title: changeDistinctFlag
     * @Description: 设置重复过滤方式，默认进行重复过滤
     * @author ZhangJianyang
     * @param distinctFlag
     * @return
     */
    default RsBuilder<T> changeDistinctFlag(boolean distinctFlag) {
        this.core().getDistinctModel().setDistinctFlag(distinctFlag);
        return this;
    }
}
